<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
?>

<!-- JavaScript -->
<script type="text/javascript" src="<?= base_url() ?>js/wufoo.js"></script>
<script src="<?= base_url() ?>js/chosen.jquery.js" type="text/javascript"></script>
<!-- CSS -->
<!--<link rel="stylesheet" type="text/css" href="<?= base_url() ?>css/form/form.css" media="screen, tv, projection" title="Default" />-->
<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>css/datepicker.css" media="screen, tv, projection" title="Default" />
<script type="text/javascript" src="<?= base_url() ?>js/datepicker.js"></script>
<link rel="stylesheet" href="<?php echo base_url() ?>css/chosen.css" />

<div id="container">
	<?
    //Setting Awal Value Jika Prosedur yang dilakukan adalah prosedur input biasa.
	$value = array(
		'id_sekolah'			=> "",
		'semester'				=> "",
		'department'			=> "",
		'isaktif'				=> "1",
		'keterangan'			=> "",
		'legend'				=> "Form Input Semester",
		'info'					=> "Form input Semester",
		'act_form'				=> "ms_semester/input_semester/"
	);
	
	//Setting Value pada form Jika melakukan prosedur Edit terhadap data tertentu.
	if($status == "edit"){
		foreach($rs_semester->result() as $row){
			$value['id_sekolah'] = $row->ID_SEK;
			$value['id_smt'] = $row->ID_SMT;
			$value['semester'] = $row->SEMESTER;
			$value['isaktif'] = $row->AKTIF;
			$value['department'] = $row->ID_DEPARTMENT;
			$value['keterangan'] = $row->KET;
		}
		$value['legend'] = "Form Input Semester";
		$value['info'] = "Form Input Semester";
		$value['act_form'] = "ms_semester/edit_semester/".$value['id_smt'];
	}//end if
	
	?>
	<?= form_open($value["act_form"],'class="wufoo" name="form_semester"'); ?>
	<fieldset class="fieldset">
	<legend class="legend">
		<?= $value["legend"] ?> |
	</legend>
	
	<div class="info">
		<div><?= $value["info"] ?></div>
	</div>
	<div>
		<?= anchor(site_url('ms_semester'),img(array('src'=>'images/main/38.png','border'=>'0','alt'=>'')).' Kembali ke daftar Semester','Menampilkan halaman Daftar Semester'); ?>
	</div>
	<?php if (!empty($err_msg)): ?>
		<div class="ret_error">
			<?php echo $err_msg; ?>
		</div>
	<?php endif; ?>
 <!-- Konten -------------------------------------------------------------------------->
 <div id="contentform">
	<ul>
		<?php if($this->session->userdata('roleid')=='0'){ //diknas ?>
		<li>
			<label class="desc">Nama Sekolah *</label>
			 <div>
                <? 
                //list tahun_ajaran
				$options_sekolah[''] = "-- Pilih Sekolah --";
				foreach($sekolah->result() as $row_sekolah){
					$options_sekolah[$row_sekolah->ID_SEKOLAH] = $row_sekolah->NAMA_SEKOLAH; 
				}
				echo form_dropdown('nama_sekolah',$options_sekolah,$value['id_sekolah'],'class="field select"');	
                ?>
            </div>
            <p class="instruct">
                Pilih Sekolah Pada Kolom ini, jika tidak ada dalam daftar maka inputkan pada Data Sekolah terlebih dahulu.			
            </p>
		</li>
		<?php echo form_error('nama_sekolah'); ?>
		<?}?>
		<!--
		<?php if($this->session->userdata('roleid')=='0'){ //diknas ?>
		<li>
			<label class="desc">Department *</label>
			 <div>
                <? 
                //list tahun_ajaran
				$options_dept[''] = "-- Pilih Department --";
				foreach($dept->result() as $rows){
					$options_dept[$rows->ID_DEPARTMENT] = $rows->NAMA_DEPARTMENT; 
				}
				echo form_dropdown('department',$options_dept,$value['department'],'class="field select"');	
                ?>
            </div>
            <p class="instruct">
                Pilih department Pada Kolom ini, jika tidak ada dalam daftar maka inputkan pada Daftar department terlebih dahulu.			
            </p>
		</li>
		<?php echo form_error('department'); ?>
		<?}else{?>
		<li>
			<label class="desc">Department *</label>
			 <div>
                <? 
                //list tahun_ajaran
				$options_dept[''] = "-- Pilih Department --";
				foreach($dept->result() as $rows){
					$options_dept[$rows->ID_DEPARTMENT] = $rows->NAMA_DEPARTMENT; 
				}
				if($value['department']==''){
					echo form_dropdown('department',$options_dept,$get_dept->ID_DEPARTMENT,'class="field select" style="background:#e0e2e3" disabled');
					echo '<input type="hidden" name="department" id="department" value="'.$get_dept->ID_DEPARTMENT.'">';
                }else{
					echo form_dropdown('department',$options_dept,$value['department'],'class="field select" style="background:#e0e2e3" disabled');	
					echo '<input type="hidden" name="department" id="department" value="'.$value['department'].'">';
				}?>
            </div>
            <p class="instruct">
                Pilih department Pada Kolom ini, jika tidak ada dalam daftar maka inputkan pada Daftar department terlebih dahulu.			
            </p>
		</li>
		<?}?>
		-->
		<?
		if($value['department']==''){
			echo '<input type="hidden" name="department" id="department" value="'.$get_dept->ID_DEPARTMENT.'">';
		}else{
			echo '<input type="hidden" name="department" id="department" value="'.$value['department'].'">';
		}
		?>
		<li>
			<label class="desc">Semester *</label>
			<div>
				<input class="field text" type="text" maxlength="3" size="3" name="semester" value="<? if(set_value('semester')!='') echo set_value('semester'); else echo $value['semester'];?>"/> 
			</div>
			<p class="instruct">
				Masukkan Semester Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('semester'); ?>
		
		<li>
			<label class="desc">Aktif?</label>
			<div>
				<input type="checkbox" name="isaktif" id="isaktif" value="1" <? if($value['isaktif']=='1') echo 'checked'; else echo '';?>>
			</div>
			<p class="instruct">
				Pilih Aktif/Tidak Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('isaktif'); ?>
		
		<li>
			<label class="desc">Keterangan</label>
			<div>
				<textarea rows="5" cols="30" name="keterangan" value="<? if(set_value('keterangan')!='') echo set_value('keterangan'); else echo $value['keterangan'];?>"><?=$value['keterangan']?></textarea>
			</div>
			<p class="instruct">
				Masukkan Keterangan Pada Kolom ini.			
			</p>
		</li>
		<?php echo form_error('keterangan'); ?>
		
		
		<li class="buttons">
		  <input id="saveForm" class="btTxt" type="submit" value="Simpan" />
		  <input name="submit" type="reset" value="Batal" />
		</li>
	</ul>
</div>
</fieldset>
<script type="text/javascript">
  $(".chzn-select").chosen();
  $(".chzn-select-deselect").chosen({allow_single_deselect:true});
</script>	
<?= form_close(); ?>
</form>
</div><!--container-->